z87 / IEEE Spectrum [Quantum]

// ==UserScript==
// @name        IEEE Spectrum [Quantum]
// @include     https://spectrum.ieee.org/*
// @version     1
// @grant       unsafeWindow
// @license     MIT
// ==/UserScript==

// interstitial
if (unsafeWindow.splashpage && unsafeWindow.splashpage.launch) unsafeWindow.splashpage.closeit();

// tracking
if (typeof unsafeWindow.initGAEventTracking == 'function') unsafeWindow.initGAEventTracking = unsafeWindow.Function.prototype;

// sticky top
if (typeof unsafeWindow.initGlobalNavMenus == 'function') {
	unsafeWindow.real_initGlobalNavMenus = unsafeWindow.initGlobalNavMenus;
	unsafeWindow.initGlobalNavMenus = exportFunction(function(headerInteractions, carousel) {
		headerInteractions.stickyTop = unsafeWindow.Function.prototype;
		//unsafeWindow.real_initGlobalNavMenus.apply(this, arguments); // arguments must be cloned
		unsafeWindow.real_initGlobalNavMenus(headerInteractions, carousel);
		delete unsafeWindow.real_initGlobalNavMenus;
		delete unsafeWindow.initGlobalNavMenus;
	}, unsafeWindow);
}

// isotope ads
unsafeWindow.$('.ad-item, .ad-item-related, .ad-module, .facebook-module').remove();

// grid layout
unsafeWindow.gmIsotopeLayout = cloneInto({ layoutMode: 'fitRows' }, unsafeWindow);
unsafeWindow.gmFitGrid = exportFunction(() => {
  unsafeWindow.$('#main.homepage div.articles').isotope(unsafeWindow.gmIsotopeLayout);
  delete unsafeWindow.gmIsotopeLayout;
  delete unsafeWindow.gmFitGrid;
}, unsafeWindow);
unsafeWindow.$(unsafeWindow.gmFitGrid);